/**
* @module @svizzle/utils/array-[string-string]
*/
import * as _ from 'lamb';
import {sliceString} from './string_proto-string.js';
/**
* Return a function extracting the portion of a string between the provided indices (first included, second excluded).
* Note that indices can be negative.
* @see {@link module:@svizzle/utils/string_proto-string.sliceString|sliceString}
*
* @function
* @arg {number[]} range - [beginIndex, endIndex]
* @arg {number} range.0 - The zero-based index at which to begin extraction
* @arg {number} [range.1] - Optional. The zero-based index before which to end extraction. If negative, starts counting from the end.
* @return {function} - Function - String -> Boolean
*
* @example
> slicerPosPos = sliceStringAt([3, 5])
> slicerPosPos('0123456789')
'34'
> slicerPosImplicit = sliceStringAt([3])
> slicerPosImplicit('0123456789')
'3456789'
> slicerPosNeg = sliceStringAt([1, -3])
> slicerPosNeg('0123456789')
'123456'
> slicerNegPos = sliceStringAt([-6, 6])
> slicerNeg3('0123456789')
'45'
*
* @since 0.5.0
*/
export const sliceStringAt = arr => _.partial(sliceString, [_.__, ...arr]);